// pages/fillinfo/fillinfo.js
var app = getApp();
Page({
  data: {
    btnTxt: "提交",
    photo: ["../../images/banner1.jpg", "../../images/banner2.jpg"],
    photo1: "../../images/banner1.jpg",
    photo2: "../../images/banner2.jpg",
    region: ['广东省', '广州市', '海珠区'],
    customItem: '全部'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(app.globalData.userInfo)
    
    wx.request({
      url: app.globalData.publicUrl+'busiAdvert/find/all', //仅为示例，并非真实的接口地址
      data: {
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        console.log(res.data)
      }
    });
  },
  uploadFile() {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths = res.tempFilePaths;
        that.setData({ "photo1": tempFilePaths });

        wx.uploadFile({
          url: app.globalData.publicUrl +'coreAttachment/upload', //仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          formData: {
            'cratmType': '997',
            'cratmDir': '997'
          },
          success: function (res) {
            var data = res.data
            console.log(data);
          }
        });
      }
    })

  },
  submitData() {
    var that = this;
    that.setData({ "btnTxt": "正在提交中..." })
  },
  bindRegionChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      region: e.detail.value
    })
  }
})